<?

  if (isset ($_GET['u_id']) && isset ($_GET['add_points']) )
   {

    $user_id = $_GET['u_id'];
    $user_add_x_points = $_GET['add_points'];

    mysql_connect ("localhost", "hof", "juillet");
    mysql_select_db ("hof");
    $req = "SELECT u_points FROM user_info WHERE u_id='" . $user_id . "' LIMIT 1";

    $rep = mysql_query ($req) or die(mysql_error());
    $rep_array = mysql_fetch_array ($rep);

    $u_points = $rep_array['u_points'] + $user_add_x_points;
 
    if ($u_points >= 25)
     {
      $req = "UPDATE user_info SET u_stars=u_stars+1  WHERE u_id='" .    $user_id . "' LIMIT 1";
      mysql_query ($req);
      $u_points = 0;
     }

    $req = "UPDATE user_info SET u_points='" . $u_points . "' WHERE u_id='" . $user_id . "' LIMIT 1";

    mysql_query ($req);

    mysql_close ();

   }

header ("Location:/hof");

?>
